<%--
  Created by IntelliJ IDEA.
  User: 郑自航
  Date: 2018/7/9
  Time: 14:40
  To change this template use File | Settings | File Templates.
--%>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<c:set var="basePath" value="${pageContext.request.contextPath}"></c:set>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>UserCar</title>
    <meta name="keywords" content="">
    <meta name="description" content="">
    <link rel="stylesheet" href="${basePath}/layui/css/layui.css">
    <script type="text/javascript" src="${basePath}/js/plugin/jquery-2.1.0.min.js"></script>
    <script type="text/javascript" src="${basePath}/js/plugin/jquery.i18n.properties.min.js"></script>
    <script src="${basePath}/layui/layui.js"></script>
</head>

<body class="page-body">
<div class="layui-inline"></div>
<div id="content">
    <form class="layui-form" action="" lay-filter="example">
        <input name="id" type="hidden" value="${id}" id="userCar_id">


                    <div class="layui-form-item">
                        <div class="layui-inline">
                            <label class="layui-form-label l-lab-text">汽车品牌id:</label>
                            <div class="layui-input-inline">
                                <select name="carBrand" id="carBrand_selectId" lay-search="">
                                    <option value="" class="l-lab-text">All</option>
                                </select>
                            </div>
                        </div>
                    </div>

                <div class="layui-form-item">
                    <div class="layui-inline">
                        <label class="layui-form-label l-lab-text">汽车型号信息:</label>
                        <div class="layui-input-inline">
                            <input name="carInfo" id="carInfo_inputId" lay-verify="" placeholder="汽车型号信息" autocomplete="true" class="layui-input"
                                   type="text">
                        </div>
                    </div>
                </div>

                <div class="layui-form-item">
                    <div class="layui-inline">
                        <label class="layui-form-label l-lab-text">车牌号:</label>
                        <div class="layui-input-inline">
                            <input name="licence" id="licence_inputId" lay-verify="" placeholder="车牌号" autocomplete="true" class="layui-input"
                                   type="text">
                        </div>
                    </div>
                </div>

                    <div class="layui-form-item">
                        <div class="layui-inline">
                            <label class="layui-form-label l-lab-text">排序:</label>
                            <div class="layui-input-inline">
                                <select name="sort" id="sort_selectId" lay-search="">
                                    <option value="" class="l-lab-text">All</option>
                                </select>
                            </div>
                        </div>
                    </div>

                <div class="layui-form-item">
                    <div class="layui-inline">
                        <label class="layui-form-label l-lab-text">汽车图片正面:</label>
                        <div class="layui-input-inline">
                            <input name="carPhotoFront" id="carPhotoFront_inputId" lay-verify="" placeholder="汽车图片正面" autocomplete="true" class="layui-input"
                                   type="text">
                        </div>
                    </div>
                </div>

                <div class="layui-form-item">
                    <div class="layui-inline">
                        <label class="layui-form-label l-lab-text">汽车背面图片:</label>
                        <div class="layui-input-inline">
                            <input name="carPhotoBack" id="carPhotoBack_inputId" lay-verify="" placeholder="汽车背面图片" autocomplete="true" class="layui-input"
                                   type="text">
                        </div>
                    </div>
                </div>

                <div class="layui-form-item">
                    <div class="layui-inline">
                        <label class="layui-form-label l-lab-text">汽车左面图片:</label>
                        <div class="layui-input-inline">
                            <input name="carPhotoLeft" id="carPhotoLeft_inputId" lay-verify="" placeholder="汽车左面图片" autocomplete="true" class="layui-input"
                                   type="text">
                        </div>
                    </div>
                </div>

                <div class="layui-form-item">
                    <div class="layui-inline">
                        <label class="layui-form-label l-lab-text">汽车右面图片:</label>
                        <div class="layui-input-inline">
                            <input name="carPhotoRight" id="carPhotoRight_inputId" lay-verify="" placeholder="汽车右面图片" autocomplete="true" class="layui-input"
                                   type="text">
                        </div>
                    </div>
                </div>

                <div class="layui-form-item">
                    <div class="layui-inline">
                        <label class="layui-form-label l-lab-text">创建人:</label>
                        <div class="layui-input-inline">
                            <input name="createUser" id="createUser_inputId" lay-verify="" placeholder="创建人" autocomplete="true" class="layui-input"
                                   type="text">
                        </div>
                    </div>
                </div>


                <div class="layui-form-item">
                    <div class="layui-inline">
                        <label class="layui-form-label l-lab-text">修改人:</label>
                        <div class="layui-input-inline">
                            <input name="updateUser" id="updateUser_inputId" lay-verify="" placeholder="修改人" autocomplete="true" class="layui-input"
                                   type="text">
                        </div>
                    </div>
                </div>


        <div class="layui-form-item">
            <div class="layui-input-block">
                <button class="layui-btn l-lab-text" lay-submit lay-filter="formDemo">OK</button>
                <button class="layui-btn layui-btn-warm l-lab-text" onclick="top.layer.close(top.addUserCar_layer)" >Cancel</button>
                <button type="reset" class="layui-btn layui-btn-primary l-lab-text">Rest</button>
            </div>
        </div>
    </form>
</div>
<div class="ibox-content">
    <table class="table-hide" id="demoTable" lay-data="{id: 'idApply'}" lay-filter="Apply"></table>
</div>
<script src="${basePath}/js/i18n.js"></script>
<script src="${basePath}/js/common.js"></script>
<script src="${basePath}/js/DateFormate.js"></script>
<script>
    $(function () {
        doTranslate();
        /*初始化下拉选*/
        var types=['userCar_carBrand','userCar_sort'];
        //批量初始化下拉选
        initBatchSelect(types,null);
    })
    function doSetEditFormData() {
        var id=$("#userCar_id").val();
        if(id){
            $.post('${basePath}/userInfo/userCar/findUserCarOne.do',{id:id},function (result) {
                if(result&&result.code==0){
                    var data=result.data;
                   // debugger
                    layui.use('form', function(){
                        var form = layui.form;
                        //表单初始赋值
                        form.val('example', {
                            "userId": data.userId,
                            "carBrand": data.carBrand,
                            "carInfo": data.carInfo,
                            "licence": data.licence,
                            "sort": data.sort,
                            "carPhotoFront": data.carPhotoFront,
                            "carPhotoBack": data.carPhotoBack,
                            "carPhotoLeft": data.carPhotoLeft,
                            "carPhotoRight": data.carPhotoRight,
                        })
                        form.render();
                    });
                }else {
                    top.myLayer.confirm(top._loadText(result.msg));
                }
            })

        }
    }
    function initForm(){
        layui.use(['form','element'], function(){
            var form = layui.form;

            //监听提交
            form.on('submit(formDemo)', function(data){
                debugger
                // top.layer.msg(JSON.stringify(data.field));
                var id=data.field.id;
                var url=id?'${basePath}/userInfo/userCar/updateUserCar.do':'${basePath}/userInfo/userCar/addUserCar.do'
                $.post(url,data.field,function (result) {
                    if(result&&result.code==0){
                        top.myLayer.msg(top._loadText('Add successful'),null,top.layer.close(top.addUserCar_layer));
                    }else{
                        top.myLayer.confirm(top._loadText('Add failed')+top._loadText(result.msg));
                    }
                })
                return false;
            });
        });
    }
</script>
</body>
</html>
